﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using SBACN.WebSite.Models;
using SBACN.WebSite.Code;

namespace SBACN.WebSite.BlackList
{
	public partial class Blacklist : MemberBasePage
	{
		protected string Name { get; set; }
		protected string CID { get; set; }
		protected void Page_Load(object sender, EventArgs e)
		{
			this.Msg.Visible = false;

			if (!IsPostBack)
			{
				ClientScript.RegisterClientScriptBlock(this.GetType(), "Msg", "$jqy(function () {$jqy.blockUI({message: $jqy('#blacklayer'),css: {top: '30%',left: '35%',width: '380px',hight: '140px'}})})", true);
			}

		}

		protected void BindDate(string SN, string SC)
		{
			Expression<Func<TB_BlackList, bool>> fun = (p => p.PersonName == SN && p.IDCard == SC);
			Expression<Func<TB_BlackList, int>> order = (p => p.ID);
			var result = DAL.DALHelper.Instance.GetList<TB_BlackList, int>(fun, order, false);
			if (result.Count > 0)
			{
				foreach (var l in result)
				{
					this.Name = l.PersonName;
					this.CID = l.IDCard;
					break;
				}
			}
			else
			{
				this.Msg.Visible = true;
			}

			this.List.DataSource = result;
			this.List.DataBind();
		}

		protected void Search_Click(object sender, EventArgs e)
		{
			string SN = this.SName.Text;
			string SC = this.SCID.Text;
			if (!string.IsNullOrWhiteSpace(SN) && !string.IsNullOrWhiteSpace(SC))
				BindDate(SN, SC);
			else
				this.Msg.Visible = true;
		}
	}
}